﻿@using CodeAbility.MonitorAndCommand.Models;

@model IEnumerable<CodeAbility.MonitorAndCommand.Models.Message>

<table id="DataTable" style="width: 100%;">
    <!-- Header -->
    <tr>
        <th>
            Sending
        </th>
        <th>
            Receiving
        </th>
        <th>
            From
        </th>
        <th>
            To
        </th>
        <th>
            Type
        </th>
        <th>
            Name
        </th>
        <th>
            Parameter
        </th>
        <th>
            Content
        </th>
        <th>
            Timestamp
        </th>
    </tr>

    <!-- Items -->
    @foreach (var item in Model)
    {        
        var cssClass = String.Empty;
        
        switch(item.ContentType)
        {
            case ContentTypes.CONTROL: 
                cssClass = "control";
                break;
            case ContentTypes.COMMAND: 
                cssClass = "command";
                break;
            case ContentTypes.DATA:
                cssClass = "data";
                break;
            case ContentTypes.HEARTBEAT:
                cssClass = "heartbeat";
                break;
        }        
        
        <tr class="@cssClass">
            <td>
                @Html.DisplayFor(modelitem => item.SendingDevice)
            </td>
            <td>
                @Html.DisplayFor(modelitem => item.ReceivingDevice)
            </td>
            <td>
                @Html.DisplayFor(modelitem => item.FromDevice) 
            </td>
            <td>
                @Html.DisplayFor(modelitem => item.ToDevice)
            </td>
            <td>
                @Html.DisplayFor(modelitem => item.ContentType)
            </td>
            <td>
                @Html.DisplayFor(modelitem => item.Name)
            </td>
            <td>
                @Html.DisplayFor(modelitem => item.Parameter)
            </td>
            <td>
                @Html.DisplayFor(modelitem => item.Content)
            </td>
            <td>
                <a href="#" data-toggle="timestamp" data-placement="top" title="@item.Timestamp.ToString("dd/MM/yyyy HH:mm:ss.fff")">
                    @item.Timestamp.ToString("HH:mm:ss.fff") <!-- "hh:mm:ss.fff tt" -->
                    @*@Html.DisplayFor(modelitem => item.Timestamp)*@
                </a>
</td>
        </tr>
    }
</table>

<br />
@*@Html.ActionLink("Purge", "Purge", "Message")*@